﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RIDA.Globals;
using System.Collections.ObjectModel;

namespace RIDA.DiagramDesigner.ViewModel
{
    [Serializable]
    public class ConnectorDecoratorViewModel : ViewModelBase
    {
        public ConnectorDecoratorViewModel()
        {
            Connectors.Add(new ConnectorViewModel()
            {
               Orientation=ConnectorOrientation.Left ,
               VerticalAlignment=System.Windows.VerticalAlignment.Center,
               HorizontalAlignment = System.Windows.HorizontalAlignment.Left
            });
            Connectors.Add(new ConnectorViewModel()
            {
                Orientation = ConnectorOrientation.Top,
                VerticalAlignment=System.Windows.VerticalAlignment.Top,
                HorizontalAlignment = System.Windows.HorizontalAlignment.Center
            });
            Connectors.Add(new ConnectorViewModel()
            {
                Orientation = ConnectorOrientation.Right,
                VerticalAlignment=System.Windows.VerticalAlignment.Center,
                HorizontalAlignment=System.Windows.HorizontalAlignment.Right
            });
            Connectors.Add(new ConnectorViewModel()
            {
                Orientation = ConnectorOrientation.Bottom,
                VerticalAlignment=System.Windows.VerticalAlignment.Bottom,
                HorizontalAlignment=System.Windows.HorizontalAlignment.Center
            });
        }

        private DesignerItemViewModel _designerItemViewModel;

        public DesignerItemViewModel DesignerItemViewModel
        {
            get { return _designerItemViewModel; }
            set
            {
                _designerItemViewModel = value;
                foreach (var item in _connectors)
                {
                    item.DesignerItemViewModel = value;
                }
            }
        }

        private ObservableCollection<ConnectorViewModel> _connectors;

        public ObservableCollection<ConnectorViewModel> Connectors
        {
            get
            {
                if (_connectors == null)
                    _connectors = new ObservableCollection<ConnectorViewModel>();
                return _connectors;
            }
        }

    }
}
